package com.example.erp.mapper.permission;

import com.example.erp.dto.permissionDTO.RoleDTO;
import com.example.erp.pojo.permission.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 列表全部查询,状态为1
 * */
@Mapper
public interface RoleMapper {
    @Select("SELECT * FROM erp_roles WHERE status = 1")
    List<Role> listAll();

    List<Role> list(RoleDTO roleDTO);

    @Select("SELECT * FROM erp_roles WHERE id = #{id}")
    Role getById(Long id);

    List<Role> getByIds(List<Long> ids);

    List<String> getNameById(@Param("ids") List<Long> ids);

    List<String> getKeyById(List<Long> ids);

    @Select("SELECT * FROM erp_roles WHERE role_name = #{name}")
    Role getByName(String name);

    @Select("SELECT * FROM erp_roles WHERE id != #{id} AND role_name = #{name}")
    Role getByIdName(@Param("id") Long id, @Param("name") String name);

    Integer count(RoleDTO roleDTO);

    Integer add(Role role);

    Integer edit(Role role);

    Integer remove(List<Long> ids);
}
